package com.demohomework.homeworkdemo.mapper;

import com.demohomework.homeworkdemo.pojo.AssSubmit;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AssSubmitMapper {
    @Insert("INSERT INTO ass_submit(ass_id,stu_id,file,info,create_at,update_at) VALUES (#{assId},#{stuId},#{file},#{info},now(),now())")
    void add(AssSubmit assSubmit);

    @Select("select * from ass_submit")
    List<AssSubmit> list(Integer id);

    @Select("select * from ass_submit where id = #{id}")
    AssSubmit findId(Integer id);

    //修改作业
    @Update("update  ass_submit set file= #{file}, info = #{info}, score = #{score}, update_at = now() where id = #{id}")

    void update(AssSubmit assSubmit);
    @Delete("delete from ass_submit where id = #{id}")
    void delete(AssSubmit assSubmit);

    //每个作业下所有提交的作业
    @Select("select * from ass_submit where ass_id = #{assId}")
    List<AssSubmit> search(Integer assId);

    @Select("select * from ass_submit where stu_id = #{stuId}")
    List<AssSubmit> searchByStudentId(Integer stuId);

    @Update("update ass_submit set score = #{score} where id = #{id}")
    void updateAverageScore(int assId, double average);
}
